<template>
	<view>
		<view  v-if="data != ''" class=" wrap bgw">
			<view class="lists_main ">
				<view @tap="successs(v)" v-for="(v,i) in data" :key="i" class="list one">
					# {{v.name}} #
				</view>
			</view>
		</view> 
		<view v-if="data == ''" class=" dataNone">
			<image src="../../static/image/huati.png" mode=""></image>
			<p>暂无集市</p>
		</view>
	</view>
</template>

<script>
	import {
		indexMarkets
	} from '../../api/api.js'

	export default {
		data() {
			return {
				keyword: '',
				pageNumber: 1,
				pageSize: 20,
				stops: 0, 
				data: []
			};
		},
		created() {
			this.init()
		},
		methods: {
			successs(v) {
				this.$navigateTo('../ji/ji?id=' + v.id)
			},
			search() {
				this.data = []
				this.pageNumber = 1
				this.stops = 0
				this.init()
			},
			checking() {
				if (this.stops == 0) {
					this.init()
				}
			},
			async init() {
				let parameter = {
					longitude: this.$store.state.longitude,
					latitude: this.$store.state.latitude,
					keyword: this.$store.state.searchText,
					isIndex: false,
					pageable: {
						pageNumber: this.pageNumber,
						pageSize: this.pageSize
					}
				}
				let datas = await indexMarkets(parameter)
				datas = datas.data
				if (datas.length != this.pageSize) {
					this.stops = 1
				}
				this.data = [...this.data, ...datas]
				this.pageNumber = this.pageNumber + 1
			}
		}
	}
</script>

<style lang="less" scoped>
	@import '../PushMarket/index.less';
</style>
